﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Configuration;
using System.Collections.Generic;

namespace WebberCross.JavaScriptBridge.WebParts
{
    /// <summary>
    /// This is a base class for webpart user controls
    /// </summary>
    public class SilverlightUserControlBase : UserControl
    {
        private SilverlightWebPartBase _webPart = null;

        public SilverlightWebPartBase WebPart
        {
            get { return this._webPart; }
            set { this._webPart = value; }
        }

        /// <summary>
        /// Formats params: key1=value1,key2=value2
        /// </summary>
        /// <param name="slParams"></param>
        /// <returns></returns>
        protected string CreateSilverlightParams(Dictionary<string, string> slParams)
        {
            string retVal = "";

            int index = 0;
            foreach (KeyValuePair<string, string> kvp in slParams)
            {
                if (index > 0) retVal += ",";
                retVal += kvp.Key;
                retVal += "=";
                retVal += kvp.Value;

                index++;
            }

            return retVal;
        }
    }
}
